package org.springboot3.project.demoapi.service;

import com.baomidou.lock.annotation.Lock4j;
import com.baomidou.lock.executor.RedisTemplateLockExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class TestService {

    private static final Logger log = LoggerFactory.getLogger(TestService.class);

    @Lock4j(name = "lock4jTest", keys = "#key", expire = 60 * 10000, acquireTimeout = 0,executor = RedisTemplateLockExecutor.class)
    public String lock4jTest(String key) {
        log.info("lock4jTest key:{}", key);
        try {
            Thread.sleep(30000L);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return "success";
    }
}
